<body>
<p>Test that request state reaches DONE even if a network error occurs.</p>
<p>Should say SUCCESS:</p>
<div id=result></div>

<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

function log(message)
{
    document.getElementById("result").innerHTML += message + "<br>";
}

function setNetworkEnabled(state)
{
    var req = new XMLHttpRequest;
    req.open("GET", "/resources/network-simulator.php?command=" + (state ? "connect" : "disconnect"), false);
    req.send("");
}

function onReadyStateChange()
{
    if (xhr.readyState == 4) {
        setNetworkEnabled(true);
        log("SUCCESS");
        if (window.testRunner)
            testRunner.notifyDone();
    }
}

setNetworkEnabled(false);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = onReadyStateChange;
xhr.open('GET', '/resources/network-simulator.php?path=/', true);
xhr.send(null);

</script>

</head>
</body>
